<nav class="navbar navbar-default">
    <div class="container">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                    data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">移动导航</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="{{ path('blog_home') }}">{{ title }}</a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
                {% for cat in categories %}
                    <li {% if category %}{% if cat.path == category.path %}class="active"{% endif %}{% endif %}>
                        <a href="{{ path('blog_home',{'path': cat.path}) }}">
                            {{ cat.name }}<span class="sr-only">(current)</span>
                        </a>
                    </li>
                {% endfor %}
            </ul>
            <ul class="nav navbar-nav navbar-right">
                {#用户状态及权限判断功能#}
                {% if is_granted("IS_AUTHENTICATED_REMEMBERED") %}
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ app.user.username }}<span class="caret"></span></a>
                        <ul class="dropdown-menu">
                            <li><a href="{{ path('fos_user_profile_show') }}">用户中心</a></li>
                            <li><a href="{{ path('fos_user_change_password') }}">{{ 'change_password.submit'|trans({}, 'FOSUserBundle') }}</a></li>
                            {% if is_granted('SUPER_ROLE_ADMIN') or is_granted('ROLE_ADMIN') %}
                            <li><a href="#">后台管理</a></li>
                            {% endif %}
                            <li role="separator" class="divider"></li>
                            <li><a href="{{ path('fos_user_security_logout') }}">{{ 'layout.logout'|trans({}, 'FOSUserBundle') }}</a></li>
                        </ul>
                    </li>
                {% else %}
                    <li>
                        <a href="{{ path('fos_user_security_login') }}">{{ 'layout.login'|trans({}, 'FOSUserBundle') }}</a>
                    </li>
                    <li>
                        <a href="{{ path('fos_user_registration_register') }}">{{ 'layout.register'|trans({}, 'FOSUserBundle') }}</a>
                    </li>
                {% endif %}
            </ul>
        </div><!-- /.navbar-collapse -->
    </div><!-- /.container-fluid -->
</nav>